`timescale 1ns / 1ps

module ps_spi(    
    output wire	    o_spi0_miso     ,
    input  wire	    i_spi0_mosi     ,
    input  wire	    i_spi0_sclk     ,
    input  wire	    i_spi0_ss0      ,
    input  wire	    i_spi0_ss1      ,
    input  wire	    i_spi0_ss2      ,

    output wire	    o_spi1_miso     ,
    input  wire	    i_spi1_mosi     ,
    input  wire	    i_spi1_sclk     ,
    input  wire	    i_spi1_ss0      ,
    input  wire	    i_spi1_ss1      ,
    input  wire	    i_spi1_ss2      ,
    // external fpga spi load                  
    output wire     o_fpga_spi0_mosi          ,
    output wire     o_fpga_spi0_sclk          ,
    //HMC7044
    output wire	    o_hmc7044_spi0_ss         ,
    inout  wire	    io_hmc7044_sdata          ,
    output wire	    o_hmc7044_spi0_sclk       ,
    //lmx2594_a                           
    output wire     o_lmx2594_a_spi1_ss      ,
    input  wire     i_lmx2594_a_spi1_miso    ,
    output wire     o_lmx2594_a_spi1_mosi    ,
    output wire     o_lmx2594_a_spi1_sclk    ,
    //lmx2594_b                           
    output wire     o_lmx2594_b_spi1_ss      ,
    input  wire     i_lmx2594_b_spi1_miso    ,
    output wire     o_lmx2594_b_spi1_mosi    ,
    output wire     o_lmx2594_b_spi1_sclk    ,
    //lmx2594_c                           
    output wire     o_lmx2594_c_spi1_ss      ,
    input  wire     i_lmx2594_c_spi1_miso    ,
    output wire     o_lmx2594_c_spi1_mosi    ,
    output wire     o_lmx2594_c_spi1_sclk
            
    );


wire hmc7044_spi0_miso;
wire hmc7044_spi0_mosi;

spi_signal_mux	u_spi_signal_mux
(
	.o_spi0_miso           ( o_spi0_miso            ),
	.i_spi0_mosi           ( i_spi0_mosi            ),
	.i_spi0_sclk           ( i_spi0_sclk            ),
	.i_spi0_ss1            ( i_spi0_ss1             ),	// hmc7044
	.i_spi0_ss2            ( i_spi0_ss2             ),	// unuse
	.i_spi0_ss0            ( i_spi0_ss0             ),	// external fpga
	.o_spi1_miso           ( o_spi1_miso            ),
	.i_spi1_mosi           ( i_spi1_mosi            ),
	.i_spi1_sclk           ( i_spi1_sclk            ),
	.i_spi1_ss1            ( i_spi1_ss1             ),	// lmx2594_b
	.i_spi1_ss2            ( i_spi1_ss2             ),	// lmx2594_c
	.i_spi1_ss0            ( i_spi1_ss0             ),	// lmx2594_a
	// external fpga
	.o_fpga_spi0_mosi      ( o_fpga_spi0_mosi       ),
	.o_fpga_spi0_sclk      ( o_fpga_spi0_sclk       ),
	//hmc7044                                       
	.o_hmc7044_spi0_ss     ( o_hmc7044_spi0_ss      ),
	.i_hmc7044_spi0_miso   ( hmc7044_spi0_miso      ),
	.o_hmc7044_spi0_mosi   ( hmc7044_spi0_mosi      ),
	.o_hmc7044_spi0_sclk   ( o_hmc7044_spi0_sclk    ),
	//lmx2594_a                                    
	.o_lmx2594_a_spi1_ss  ( o_lmx2594_a_spi1_ss     ),
	.i_lmx2594_a_spi1_miso( i_lmx2594_a_spi1_miso   ),
	.o_lmx2594_a_spi1_mosi( o_lmx2594_a_spi1_mosi   ),
	.o_lmx2594_a_spi1_sclk( o_lmx2594_a_spi1_sclk   ),
	//lmx2594_b                                    
	.o_lmx2594_b_spi1_ss  ( o_lmx2594_b_spi1_ss     ),
	.i_lmx2594_b_spi1_miso( i_lmx2594_b_spi1_miso   ),
	.o_lmx2594_b_spi1_mosi( o_lmx2594_b_spi1_mosi   ),
	.o_lmx2594_b_spi1_sclk( o_lmx2594_b_spi1_sclk   ),	
	//lmx2594_c                                    
	.o_lmx2594_c_spi1_ss  ( o_lmx2594_c_spi1_ss     ),
	.i_lmx2594_c_spi1_miso( i_lmx2594_c_spi1_miso   ),
	.o_lmx2594_c_spi1_mosi( o_lmx2594_c_spi1_mosi   ),
	.o_lmx2594_c_spi1_sclk( o_lmx2594_c_spi1_sclk   )		
	
);

spi_4to3_conv	u_hmc7044_spi_conv
(
	.io_spi_sdata   ( io_hmc7044_sdata    ),
	.i_spi_ss       ( o_hmc7044_spi0_ss   ),
	.i_spi_sclk     ( o_hmc7044_spi0_sclk ),
	.o_spi_miso     ( hmc7044_spi0_miso   ),
	.i_spi_mosi     ( hmc7044_spi0_mosi   )
);


endmodule